home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-15 | 2.3 KB | 60 lines | [TEXT/gamI] |
- ; ----------------------------------------------------------------------------
- ; File: tools.scm
- ; Description: Assorted tools that I never use.
- ; Author: Mike Brumbelow @ ART
- ; Created: 1-Oct-94
- ; Language: Scheme
- ; Status: Experimental (Swim at your own risk)
- ;
- ; (c) Copyright 1994, Advanced Robotic Technologies, Inc.
- ; All Rights Reserved.
- ;
- ; ----------------------------------------------------------------------------
-
- ;; ---- Point-on-Line Test ----
- ;;
- (define (test x0 y0 x1 y1 x2 y2)
- (let* ((x1 x1)
- (y1 y1)
- (x2 x2)
- (y2 y2)
- (m (exact->inexact (/ (- y2 y1) (- x2 x1))))
- (b (exact->inexact (- y1 (* m x1))))
- (b0 (ceiling b))
- (b1 (floor b)))
- (if (= y0 (+ (* m x0) b))
- (format #t "~% Points: (~s, ~s) are on the line" x0 y0)
- (format #t "~% Points: (~s, ~s) are not the line" x0 y0))
- (if (= y0 (+ (* m x0) b0))
- (format #t "~% Points: (~s, ~s) are on the line" x0 y0)
- (format #t "~% Points: (~s, ~s) are not the line" x0 y0))
- (if (= y0 (+ (* m x0) b1))
- (format #t "~% Points: (~s, ~s) are on the line" x0 y0)
- (format #t "~% Points: (~s, ~s) are not the line" x0 y0))
- (format #t "~% m-> ~5 b-> ~5 b0-> ~5 b1-> ~5 "m b b0 b1)))
-
- (define (near-line x1 y1 x2 y2 x3 y3 barrier)
- (let* ((vx1 (- x2 x1))
- (vy1 (- y2 y1))
- (vx2 (- x3 x1))
- (vy2 (- y3 y1))
- (v1v2 (+ (* vx1 vx2) (* vy1 vy2)))
- (mag-v1 (sqrt (+ (expt vx1 2) (expt vy1 2))))
- (mag-v2 (sqrt (+ (expt vx2 2) (expt vy2 2))))
- (a (/ v1v2 mag-v1))
- (distance (abs (sqrt (- (expt mag-v2 2) (expt a 2))))))
- (format #t "~% Vx1 = ~s~%" vx1)
- (format #t " Vy1 = ~s~%" vy1)
- (format #t " Vx2 = ~s~%" vx2)
- (format #t " Vy2 = ~s~%" vy2)
- (format #t " V1.V2 = ~s~%" v1v2)
- (format #t "Magnitude V1 = ~s~%" mag-v1)
- (format #t "Magnitude V2 = ~s~%" mag-v2)
- (format #t " A = ~s~%" a)
- (format #t " Distance = ~s~%" distance)
- (format #t "Line Barrier = ~s~%~%" barrier)
- (if (< distance barrier)
- (format #t "<Inside the line barrier>~%")
- (format #t "<Outside the line barrier>~%"))
- (< distance barrier)))
-